Skip to content

Conversation

VincentLanglet
Copy link
Contributor

}

$type = $this->getFlagsValue($flagsType);
if (!$type instanceof ConstantIntegerType) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In next PR I'll add support for union of ConstantIntegerType

['%s|false', ''],
['%s|false', ', $mixed'],
['%s|false', ', ["flags" => $mixed]'],
['mixed', ', $mixed'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, with a mixed flag it's not necessary %s|false cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY

['%s|false', ', $mixed'],
['%s|false', ', ["flags" => $mixed]'],
['mixed', ', $mixed'],
['mixed', ', ["flags" => $mixed]'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, with a mixed flag it's not necessary %s|false cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY

Comment on lines +7387 to +7388
['mixed', ', $mixed'],
['mixed', ', ["flags" => $mixed]'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, with a mixed flag it's not necessary bool cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY

{
assertType('int', filter_var($int, FILTER_VALIDATE_INT));
assertType('int|false', filter_var($int, FILTER_VALIDATE_INT, $options));
assertType('mixed', filter_var($int, FILTER_VALIDATE_INT, $options));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong, with a array $options, the flag might be mixed.

And with a mixed flag it's not necessary mixed cause you might pass FILTER_NULL_ON_FAILURE or FILTER_FORCE_ARRAY or FILTER_REQUIRE_ARRAY

@VincentLanglet VincentLanglet marked this pull request as ready for review October 7, 2025 08:51
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent parameter evaluation of filter_var()
2 participants